package com.neusoft.neumooc.dao;

import java.util.Map;

import org.springframework.stereotype.Repository;

import com.neusoft.core.common.BaseDAO;
import com.neusoft.core.common.exception.DAOException;
import com.neusoft.neumooc.VO.UserVO;

@Repository
public class UserDAOImpl extends BaseDAO implements UserDAO {

	/**
	 * @Title: getUserByName
	 * @Description: TODO 通过登录名获取用户
	 * @param userName
	 * @return Map<String, Object>
	 * @throws DAOException
	 */
	private final static String QUERY_USER = "select * from user where username=?";

	@Override
	public Map<String, Object> getUserByName(String userName)
			throws DAOException {
		Object[] obj = { userName };
		return this.queryForMap(QUERY_USER, obj);
	}

	/**
	 * @Title: register
	 * @Description: TODO 用户注册
	 * @param userVO
	 * @throws DAOException
	 */
	private static final String REGISTER_SQL = "INSERT INTO user(id,uId,userName,password,phone,address,time,name) values(:id,:uId,:userName,:password,:phone,:address,now(),:name)";

	@Override
	public void register(UserVO userVO) throws DAOException {
		this.update(REGISTER_SQL, userVO);
	}
}
